import requests


def download_video(url, filename):
    response = requests.get(url, stream=True)
    if response.status_code == 200:
        with open(filename, 'wb') as f:
            for chunk in response.iter_content(1024):
                f.write(chunk)
        print(f"Video {filename} downloaded successfully.")
    else:
        print(f"Failed to download video. Status code: {response.status_code}")

    # 使用函数下载视频


video_url = "https://vdept3.bdstatic.com/mda-qcaaujwdd8j13e7t/720p/h264/1710142782448859896/mda-qcaaujwdd8j13e7t.mp4?v_from_s=hkapp-haokan-nanjing&auth_key=1710221485-0-0-c947507202a9edf12a38df507c3d52db&bcevod_channel=searchbox_feed&pd=1&cr=2&cd=0&pt=3&logid=1885651480&vid=14568274305234122598&klogid=1885651480&abtest="  # 视频URL
video_filename = "f21010310俞佳文.mp4"  # 下载后的视频文件名
download_video(video_url, video_filename)